//
//  WmcTeamCloudInviteMemberVM.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/9/14.
//

import Foundation

class WmcTeamCloudInviteMemberVM: WmcBaseVM {
    /// 团队相册
    var teamAblum: WmcMediaTeamAlbumModel?
    /// 团队成员
    var teamMember: WmcTeamMemberModel?

    let inviationInfo: BehaviorRelay<WmcInviationInfoModel?> = .init(value: nil)

    /// 复制团队号
    /// - Parameter teamId: 团队ID
    /// - Returns: description
    func copyTeamId(teamId: String? = "") {
        let pasteboard = WmcPasteboard()
        pasteboard.plainText = teamId ?? ""
        pasteboard.saveToPasteboard()
        WmcHudManager.toast("复制成功")
    }

    /// 获取邀请相关的信息
    /// - Returns: description
    func getQrcode() {
        guard let teamId = teamAblum?.teamId else { return }
        WmcHudManager.loading()
        WmcMediaTeamManagerAPI.getTeamInviationInfo(teamId: teamId).subscribe { [weak self] info in
            guard let weakSelf = self else { return }
            WmcHudManager.dismiss()
            weakSelf.inviationInfo.accept(info)
        } onError: { error in
            WmcHudManager.toast(error)
            WmcHudManager.dismiss()
        }.disposed(by: rx.disposeBag)
    }
}
